﻿//-----------------------------------------------------------------
//
// @(#)$Id: BadProductReport.aspx.cs,v 1.0 2013/12/16 9:48:16 lichunhua Exp $
// @(#)$Author: lichunhua  $
// @(#)$Date: 2013/12/16 9:48:16 $
// @(#)$Description:
//
//
//
//                 All Rights Reserved.
//-----------------------------------------------------------------
using System;
using System.Data;
using System.Web.UI.WebControls;
using ebay.Dal;

public partial class UI_Report_BadProductReport : System.Web.UI.Page
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        //商品等级
        ddlProductGrade.Items.Insert(0, new ListItem("《--请选择--》", ""));
        ddlProductGrade.Items.Insert(1, new ListItem("免检", "免检"));
        ddlProductGrade.Items.Insert(2, new ListItem("合格", "合格"));
        ddlProductGrade.Items.Insert(3, new ListItem("待观察", "待观察"));
        ddlProductGrade.Items.Insert(4, new ListItem("下架", "下架"));
    }
    protected void Page_Load(object sender, EventArgs e)
    {        
        WebUtility.CheckRight();
        if (!IsPostBack)
        {
            ebay.Dal.Report report = new Report();
            Repeater1.DataSource = report.GetData("");//默认为全部
            Repeater1.DataBind();
        }
    }
    //导出数据
    protected void btnBadProduct_Click(object sender, EventArgs e)
    {
        if (Session["UserId"] == null)
        {
            WebUtility.ShowMsg("登陆超时,请重新登陆", this);
            return;
        }
        string grade = ddlProductGrade.Value;
        ebay.Dal.Report rep = new Report();
        DataTable dt = rep.GetData(grade);  //获得数据     
        dt.TableName = "BadProductCount";
        if (dt.Rows.Count > 0)
        {
            DataSetToExcel.DataSetOutExcel(dt, "坏品率统计表");
        }
        else
        {
            WebUtility.ShowMsg("无导出数据", this);
        }
    }
    //数据查询
    protected void btnQuery_Click(object sender, EventArgs e)
    {
        string grade = ddlProductGrade.Value;
        ebay.Dal.Report rep = new Report();       
        DataTable dt = rep.GetData(grade);
        Repeater1.DataSource = dt;
        Repeater1.DataBind();
    }
}
